//-----------------------------------------------
//-      - Define a Shape and its vertices
//-----------------------------------------------

/* These defines allow the header to be included more than once
in the same file */
#ifndef __IGU_FIGURE__
#define __IGU_FIGURE__

#include <iostream>

#include "Vec2.h"

class Trajectory;

class Shape
{
public:

	struct XY {int x,y; };

	// Constructor (initializes the Shape)
	Shape();

	// Renders the Shape with OpenGL
	void render() const;

	// Updates the next vertex
	void updateNextVertex(const Vec2& nueva_posicion);

	// Adds the current vertex (_nextVertex) to the Shape
	void addNextVertex();

	// Returns the num-th vertex
	const Vec2& vertex(unsigned int num) const;

	// Returns the number of vertices
	unsigned int nVertices() const;

	// Save the Shape. 
	void save( std::ostream& output);

	// Loads the Shape. 
	void load( std::istream& input);

	void deleteAll();

	void setColor(float red, float green, float blue);

	void deleteLastVertex();

	void Create3DObjectFromTrajectory(Trajectory * traj);

	void render3D();

	int Convex(Vec2 *p,int n);

	int CounterClockWise(Vec2 * p, int n, int shapeT);

	void CreateNormalsFor3DObject(Trajectory * traj);

	void render3DSolid();

	void DrawNormals();


private:
	Vec2 _nextVertex; // Next vertex to be added
	VectorVec2 _vertices; // Vector of vertices in the Shape

	GLfloat* vert3d;
	
	GLint * indices;
	GLint * indicesFace1;
	GLint * indicesFace2;

	GLfloat * normals;
	GLfloat * normalsFace1;
	GLfloat * normalsFace2;


	GLfloat * colors;

	int numVert;
	int indexSize;
	int faceIndexes;

	int CONCAVE;
	int CONVEX;

	int CW;
	int CCW;
	int ccwQ;

	float redCol, greenCol, blueCol; // Colors of the shape

	
	
};


#endif

